package gtkwire.widget;

import gtkwire.*;
import gtkwire.widget.utils.*;
import java.io.File;

/**
*A file chooser dialog, suitable for "File/Open" or "File/Save" commands. TEST CREATE
*/
public class GtkFileChooserDialog extends GtkDialog implements GtkFileChooser
{
	private String title;
	private GtkWindow parent;
	private GtkFileChooserAction action;

	/**
	*
	*/
        public GtkFileChooserDialog( String title, GtkWindow parent, GtkFileChooserAction action )
        {
		super();
		this.widgetType = WT_GtkFileChooserDialog;
		this.title = title;
		this.parent = parent;
		this.action = action;
		gtkCreate();// test creating
        }

	/**
	*
	*/
        public GtkFileChooserDialog( String name, GladeKey key )
        {
		super( name, key );
		this.widgetType = WT_GtkFileChooserDialog;
        }

	protected String[] getCreateData()
	{
		if( action == null ) return null;//to block super gtk creation.
		String[] msg = new String[3];
		msg[ 0 ] = title;
		if( parent != null ) msg[ 1 ] = parent.getName();
		else  msg[ 1 ] = "##%%&&%%##((//";
		msg[2] = action.getMode();
		return msg;
	}


	public void setCurrentFolder( String path )
	{
		 FileChooserMethods.setCurrentFolder( this, path );
	}
	/**
	*Gets the filename for the currently selected file in the file selector. 
	*If multiple files are selected, one of the filenames will be returned at random.
	*If the file chooser is in folder mode, this function returns the selected folder.
	*/
	public File getFile()
	{
		return FileChooserMethods.getFile( this );
	}

	/**
	*Sets filename as the current filename for the file chooser, 
	*by changing to the file's parent folder and actually selecting the file in list. 
	*If the chooser is in GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name will also appear in the dialog's file name entry.
	*/
	public void setFile( File f )
	{
		 FileChooserMethods.setFile( this, f );
	}

}//end class
